import React,{Component} from 'react'
import "./index.css"
export default class Header extends Component{
  doSomething=(event)=>{
    const uuid = require('uuid')
    const {keyCode,target}=event
    if (!target.value.trim()) return
      if(keyCode!==13) return
      const obj={
        id:uuid.v4(),
        td:target.value,
        done:false
      }
      this.props.addTodo(obj)
      target.value=''
  }
  render(){
    return (
      <div className='inputbox'>
        <input type="text" onKeyUp={this.doSomething} name="" id="" />
      </div>
    )
  }
}

